<template>
  <div>
    <!-- 头部 -->
    <div class="top-container">
      <div class="info-box">
        <van-image class="myImage" round fit="cover" :src="userInfo.photo" />
        <h2 class="name">
          {{ userInfo.name }}<br />
          <van-tag color="#ffffff" text-color="#3296fa">{{
            userInfo.birthday
          }}</van-tag>
        </h2>
      </div>
    </div>
    <!--  -->
    <div>
      <van-row class="myCol">
        <van-col span="8"
          ><van-icon
            name="newspaper-o"
            class="myIcon"
            size="20"
            color="#a5bfff"
          /><br />
          我的作品</van-col
        >
        <van-col span="8"
          ><van-icon
            name="star-o"
            class="myIcon"
            size="20"
            color="#ff4f00"
          /><br />我的收藏</van-col
        >
        <van-col span="8"
          ><van-icon
            name="tosend"
            size="20"
            class="myIcon"
            color="#ffb100"
          /><br />阅读历史</van-col
        >
      </van-row>
    </div>
    <!--  -->
    <div>
      <van-cell icon="edit" title="编辑资料" is-link to="/edit" />
      <van-cell icon="chat-o" title="小智同学" is-link />
      <van-cell icon="setting-o" title="系统设置" is-link />
      <van-cell icon="warning-o" title="退出登录" is-link @click="logout" />
    </div>
  </div>
</template>

<script>
// import { getUserInfo } from '../../api/my.js'
import { removeToken } from '../../utils/token'
import { mapState } from 'vuex'
export default {
  data () {
    return {
      // userInfo: ''
    }
  },
  /* created () {
    getUserInfo().then(data => {
      // console.log(data)
      this.userInfo = data.data.data
    })
  }, */
  computed: mapState(['userInfo']),
  /* computed: {
    userInfo () {
      return this.$store.state.userInfo
    }
  }, */
  methods: {
    logout () {
      this.$dialog
        .confirm({
          title: '温馨提示',
          message: '您确定要退出本系统吗？'
        })
        .then(() => {
          removeToken()
          // this.userInfo = {}
          this.$store.commit('setUserInfo', {})
          this.$router.push({ path: '/index' })
        })
        .catch(() => {})
    }
  }
}
</script>

<style scoped>
.info-box {
  background-color: #3296fa;
  display: flex;
  height: 100px;
  align-items: center;
  padding-left: 10px;
}
.myImage {
  width: 60px;
  height: 60px;
}
.name {
  color: white;
  font-size: 14px;
  margin-left: 10px;
}
.myCol {
  text-align: center;
  font-size: 12px;
  margin-top: 10px;
}
</style>
